/**
 * Copyright (c) 2024-2025 National Fundamental Software of China Co., Ltd.
 *
 * You should have find a copy of NFSChina License. If not, please contact us
 * by email <os_support@nfschina>
 *
**/

/*
    SPDX-FileCopyrightText: 2011 Martin *Gräßlin <mgraesslin@kde.org>
    SPDX-FileCopyrightText: 2012 Gregor Taetzner <gregor@freenet.de>
    SPDX-FileCopyrightText: 2014 Sebastian Kügler <sebas@kde.org>
    SPDX-FileCopyrightText: 2015-2018 Eike Hein <hein@kde.org>
    SPDX-FileCopyrightText: 2021 Mikel Johnson <mikel5764@gmail.com>
    SPDX-FileCopyrightText: 2021 Noah Davis <noahadvs@gmail.com>
    SPDX-FileCopyrightText: 2022 Nate Graham <nate@kde.org>

    SPDX-License-Identifier: GPL-2.0-or-later
 */
import QtQuick 2.15
import QtQml 2.15
import QtQuick.Layouts 1.15
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 3.0 as PC3
import org.kde.kirigami 2.16 as Kirigami

AbstractKickoffItemDelegate {
    id: root

    property real scaleFactor: PlasmaCore.Units.devicePixelRatio;
    property bool compact: Kirigami.Settings.tabletMode ? false : plasmoid.configuration.compactMode
    property bool isCategoryConent: false

    icon.width: 24 * scaleFactor
    icon.height: 24 * scaleFactor
    labelTruncated: label.truncated

    dragIconItem: icon
    contentItem: RowLayout {
        id: row
        spacing: 18 * scaleFactor

        PlasmaCore.IconItem {
            id: icon
            implicitWidth: root.icon.width
            implicitHeight: root.icon.height
            Layout.alignment: Qt.AlignVCenter

            animated: false
            usesPlasmaTheme: false
            roundToIconSize: false

            source: root.decoration || root.icon.name || root.icon.source
        }

        PC3.Label {
            id: label
            Layout.leftMargin: 0
            Layout.preferredHeight: implicitHeight
            text: root.text
            textFormat: Text.PlainText
            elide: Text.ElideRight
            maximumLineCount: 1
        }

        Item {
            Layout.fillWidth: true
        }
    }

    Loader {
        id: separatorLoader

        anchors.left: root.left
        anchors.right: root.right
        anchors.verticalCenter: root.verticalCenter

        active: root.isSeparator

        asynchronous: false
        sourceComponent: PlasmaCore.SvgItem {
            width: parent.width
            height: KickoffSingleton.lineSvg.horLineHeight

            svg: KickoffSingleton.lineSvg
            elementId: "horizontal-line"
        }
    }
}
